package io.github.lee.core.repository

import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody

open class BaseRepository {
    protected fun toRequestBody(any: Any, contentType: MediaType? = null): RequestBody =
        Gson().toJson(any).toRequestBody(
            contentType ?: "application/json; charset=UTF-8".toMediaTypeOrNull()
        )

}